// source --> https://adventureability.org/wp-content/plugins/geodir_review_rating_manager/js/geodir-plupload.js?ver=4.9.13 jQuery.fn.exists = function() { return jQuery(this).length > 0; } jQuery(document).ready(function($) { geodir_review_upload_init(); }); var geodir_totalImg; function geodir_review_upload_init() { if (jQuery(".gd-plupload-upload-uic").exists()) { var pconfig = false; var msgErr = ''; jQuery(".gd-plupload-upload-uic").each(function() { var $this = jQuery(this); var id1 = $this.attr("id"); var imgId = id1.replace("plupload-upload-ui", ""); gd_plu_show_thumbs(imgId); pconfig = JSON.parse(geodir_reviewrating_plupload_localize.geodir_reviewrating_plupload_config); pconfig["browse_button"] = imgId + pconfig["browse_button"]; pconfig["container"] = imgId + pconfig["container"]; pconfig["drop_element"] = imgId + pconfig["drop_element"]; pconfig["file_data_name"] = imgId + pconfig["file_data_name"]; pconfig["multipart_params"]["imgid"] = imgId; pconfig["multipart_params"]["_ajax_nonce"] = $this.find(".ajaxnonceplu").attr("id").replace("ajaxnonceplu", ""); if ($this.hasClass("gd-plupload-upload-uic-multiple")) { pconfig["multi_selection"] = true; } if ($this.find(".plupload-resize").exists()) { var w = parseInt($this.find(".plupload-width").attr("id").replace("plupload-width", "")); var h = parseInt($this.find(".plupload-height").attr("id").replace("plupload-height", "")); pconfig["resize"] = { width: w, height: h, quality: 90 }; } var uploader = new plupload.Uploader(pconfig); uploader.bind('Init', function(up) {}); uploader.init(); uploader.bind('Error', function(up, files) { jQuery('#upload-error').addClass('upload-error'); if (files.code == -600) { msgErr = geodir_reviewrating_plupload_localize.geodir_err_file_size; } else if (files.code == -601) { msgErr = geodir_reviewrating_plupload_localize.geodir_err_file_type; } else { msgErr = files.message; } jQuery('#upload-error').html(msgErr); }); // a file was added in the queue geodir_totalImg = 0; geodir_limitImg = geodir_reviewrating_plupload_localize.geodir_image_limit; uploader.bind('FilesAdded', function(up, files) { jQuery('#upload-error').html(''); jQuery('#upload-error').removeClass('upload-error'); if (geodir_limitImg) { if (geodir_totalImg == geodir_limitImg && parseInt(geodir_limitImg) > 0) { while (up.files.length > 0) { up.removeFile(up.files[0]); } // remove images jQuery('#upload-error').addClass('upload-error'); jQuery('#upload-error').html(geodir_reviewrating_plupload_localize.geodir_err_file_limit); return false; } if (up.files.length > geodir_limitImg && parseInt(geodir_limitImg) > 0) { while (up.files.length > 0) { up.removeFile(up.files[0]); } // remove images msgErr = geodir_reviewrating_plupload_localize.geodir_err_file_pkg_limit; msgErr = msgErr.replace("%s", geodir_limitImg); jQuery('#upload-error').addClass('upload-error'); jQuery('#upload-error').html(msgErr); return false; } if (parseInt(up.files.length) + parseInt(geodir_totalImg) > parseInt(geodir_limitImg)) { while (up.files.length > 0) { up.removeFile(up.files[0]); } // remove images msgErr = geodir_reviewrating_plupload_localize.geodir_err_file_remain_limit; msgErr = msgErr.replace("%s", (parseInt(geodir_limitImg) - parseInt(geodir_totalImg))); jQuery('#upload-error').addClass('upload-error'); jQuery('#upload-error').html(msgErr); return false; } } jQuery.each(files, function(i, file) { $this.find('.filelist').append('